<%inherit file="/base/user.html"/>

<p>You are visiting the Grid Monitor of the ${config['gridname']}.
On this page you find a personalized <span class="emph"> tactical overview </span> on the current 
situation on the Grid. 
</p>

<table id="user_overview"  width="900" summary="Personalized tactical overview for users">
    <caption>
        Tactical Overview
    </caption>
    
    <tr> 
        <th class="gm corner_left" scope="col">Service/Performance</th> 
        <th class="gm" scope="col" colspan=2>(Services) Status</th>
        <th class="gm corner_right" scope="col">Details</th> 
    </tr>

    <tr>
        <td> Core Services </td>
        <td colspan=2 id='cores'> 
            Hosts: 
            <div class="ok_status" status = 'host_up'> </div>
            <div class="ok_status"  status= 'host_sdown'> </div>
            <div class="error_status" status = 'host_down'> </div>
            <div class="undef_status" status= 'host_unknown'>no info yet </div>
            <br />
            Plugins: 
            <div class="ok_status" status='plugins_ok'>  </div>
            <div class="warn_status" status = 'plugins_warn'>  </div>
            <div class="error_status" status ='plugins_crit'>  </div>
            <div class="undef_status" status = 'plugins_unknown'> no info yet </div>
        </td>        
        <td align='center'> ${h.link('/user/overview/nagios#core','details')}</td>
    </tr>

    <tr>
        <td> Computing Elements (Services) </td>
        <td colspan=2 id='ces'> 
            Hosts: 
            <div class="ok_status" status = 'host_up'></div>
            <div class="ok_status"  status= 'host_sdown'> </div>
            <div class="error_status" status = 'host_down'> </div>
            <div class="undef_status" status= 'host_unknown'>no info yet </div>
            <br />
            Plugins: 
            <div class="ok_status" status='plugins_ok'>  </div>
            <div class="warn_status" status = 'plugins_warn'>  </div>
            <div class="error_status" status ='plugins_crit'>  </div>
            <div class="undef_status" status = 'plugins_unknown'> no info yet </div>
        </td>        
        <td align='center'> ${h.link('/user/overview/nagios#ces','details')}</td>
    </tr>
    
    <!-- IF ANY CLUSTER HAS NO_QUEUE report it here. Will NOT  be dynamically updated! -->
    %if c.no_queue_clusters:
    <tr>
        <td>Cluster(s) with Queue problem</td>
        <td colspan=2>
            % for (display_name, hostname) in c.no_queue_clusters:
                <% cpath =  '/user/clusters/show/' +  hostname %>
                ${h.link(cpath, display_name)} 
                %if hostname not in c.now_scheduled_down:
                    <span class="error_status"> 
                    (NO QUEUE)
                    </span><br/>
                %else:
                    scheduled downtime
                %endif
            %endfor
        </td>
        <td align='center'> ${h.link(cpath, 'details')}</td>
    </tr>
    %endif    

    <tr>
        <td> My Jobs </td>
        <td colspan=2 id='jobs'> 
            <span class="undef_status"> no info yet</span>
       </td>
        <td align='center'>${h.link('/user/jobs','details')}</td>
    </tr>

<!-- Grid load --> 
<tr class="table_row_emph" align="center"> 
    <td colspan=3>
    <span class="emph">Grid Load </span></td>
    <td> 
     <span class="emph">${h.link('/user/clusters','details')}</span>
    </td>
</tr>

<tr class='nohover'> 
    <!-- plots -->
    <td class="plot"><div id= "grid_load_cpu"></div></td>
    <td class="plot"><div id= "grid_load_queue"></div></td>
    <!-- DETAILS -->
    <td colspan="2" align="center" id="grid_load_table"> </td>
</tr>
 <tr id='max_cluster'> <!-- MAX LOAD CLUSTER --> </tr>
    
    <tr id='min_cluster'> <!-- MIN LOAD CLUSTER --> </tr>
 

    <!-- DOWNTIME/MAINTENANCE-->
    %if c.down_time_items: 
    <tr class="table_row_emph" align="center"> 
    <td colspan=4>
    <span class="emph"> Scheduled Downtimes</span>
    </td>
    </tr>

    %for host in  c.down_time_items.keys():
    <tr> 
    <td>
        <b>Host</b>: ${host} <br />
        %if c.down_time_items[host]['services']: # i.e. list not empty
            <b>Services</b>: 
            %for service in c.down_time_items[host]['services']:
                '${service}' &nbsp;
            %endfor
        %endif
    </td>
    <td colspan="3"> Will be down from: ${c.down_time_items[host]['start_t']} to ${c.down_time_items[host]['end_t']}  <br/>
        Reason: ${c.down_time_items[host]['reason']}
    </td>
    </tr>
    %endfor
    %endif
    <tr>
    <td colspan=4>
    <img src="/rrd/Gridstats_ch24.png" alt="Grid CPU load (last 24 hours)">   
    </td>
    </tr>
    <tr>
    <td colspan=4>
    <img src="/rrd/Gridstats_qh24.png" alt="Grid queue backlog (last 24 hours)">   
    </td>
    </tr>

</table>

<script language="javascript" type="text/javascript">
function _nagiosSummary(){
    nagiosSummary('cores');
    nagiosSummary('ces');
}

function refreshCallback(){
    var secs = 120;
    setInterval( "_nagiosSummary()", secs * 1000);
}

$(document).ready(function() {
    _nagiosSummary();
    refreshCallback();
});
</script>

    
<%def name="js()">
    ${parent.js()}
    ${self.js_link("/js/qtip/jquery.qtip-1.0.0-rc3.min.js")}
    ${self.js_link("/js/nagios_stats.js")}
    ${self.js_link("https://www.google.com/jsapi")}
    ${self.js_link("/js/grid_load.js")}
    ${self.js_link("/js/job_states.js")}
</%def>

